<!DOCTYPE html>
<html lang="en" ng-app="app">

<head>
    <meta charset="UTF-8">
    <title>登录页</title>
    <link rel="stylesheet" href="/public/css/bootstrap.min.css">
    <link rel="stylesheet" href="/public/css/font-awesome.min.css">
    <link rel="stylesheet" href="/public/css/common.css">
    <link rel="stylesheet" type="text/css" href="/public/css/mine.css">
</head>

<body ng-controller="login" style="position:relative;">
    <!--背景用来放置一张背景图片-->
    <div class="login-bg"></div>
    <login-directive></login-directive>
    <script src="/public/libs/angular.min.js"></script>
    <script src="/public/libs/angular-ui-router.js"></script>
    <script src="/public/libs/ui-bootstrap-tpls-1.3.0.min.js"></script>
    <script src="/public/libs/jquery-1.11.3.js"></script>
    <script src="/public/libs/jquery.form.js"></script>
    <script>
        var app = angular.module("app", []);
        app.controller("login", function($scope, $http, $window) {
            $http({
                url: "http://192.168.99.143:3366/" + "/Login/index",
                method: "get",
                dataType: "json"
            }).success(function(data) {
                $scope.account = data.userName;
            });
            $scope.submit = function() {
                $("form").ajaxSubmit({
                    type: "post",
                    dataType: "json",
                    url: "http://192.168.99.143:3366/" + "/Login/login",
                    success: function(data) {
                        console.log(data);
                        if (data.code == 0) {
                            // alert(data.msg);
                            $window.location.href = "main.html";
                        } else {
                            alert(data.msg);
                        }
                    },
                    fail: function(data) {}
                })
            }
        })
        app.directive("loginDirective", function() {
            return {
                restrict: "EA",
                templateUrl: "/views/directives/login-box.html",
                replace: true,
                // scope: false,
                link: function(scope, element, attr) {

                }
            }
        })
    </script>
</body>

</html>